<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class CountyLocale{

    const  All_Others = 'All Others';

    const  Allegany = 'Allegany';
    const  Anne_Arundel = 'Anne Arundel';
    const  Baltimore_City = 'Baltimore City';
    const  Baltimore_County = 'Baltimore County';
    const  Calvert = 'Calvert';
    const  Caroline = 'Caroline';
    const  Carroll = 'Carroll';
    const  Cecil = 'Cecil';
    const  Charles = 'Charles';
    const  Dorchester = 'Dorchester';
    const  Frederick = 'Frederick';
    const  Garrett = 'Garrett';
    const  Harford = 'Harford';
    const  Howard = 'Howard';
    const  Kent = 'Kent';
    const  Montgomery = 'Montgomery';
    const  Prince_Georges = 'Prince George\'s';
    const  Queen_Annes = 'Queen Anne\'s';
    const  St_Marys = 'St. Mary\'s';
    const  Somerset = 'Somerset';
    const  Talbot = 'Talbot';
    const  Washington = 'Washington';
    const  Wicomico = 'Wicomico';
    const  Worcester = 'Worcester';

    // DE additional
    const  New_Castle = 'New Castle';
    const  Sussex = 'Sussex';

    // FL
    const Miami_Dade = 'Miami-Dade';

    private $county;

    /**
     * This is used to support GWT serialization, do not use this constructor for other purposes.
     */
    public function CountyLocale($county) {
        $this->county = $county;
    }

    public function getName() {
        return $this->county;
    }

//    public static function valueOf($state, $countyName) {
//
//        $allCountyLocale = getCountyLocalse($state);
//        
//        foreach ($allCountyLocale as $countyLocale)
//            if ($countyLocale->getName()->equals($countyName)) 
//                return $countyLocale;
//
//        return null;
//    }
//
//    public static function valueOf($countyName) {
//
//        $allStates = EState::getAllStates();
//        foreach ($allStates as $state)
//        {
//            $allCountyLocale = getCountyLocalse($state);
//            foreach ($allCountyLocale as $countyLocale)
//                if ($countyLocale->getName()->equals($countyName)) 
//                    return $countyLocale;                
//        }
//
//        //return "County name is not recognized " . $countyName;
//        return null;
//    }

    public static function getCountyLocales($state) {
        $countyLocales = array();

        if ($state == EState::MD) {
            $countyLocales[] = new CountyLocale("Allegany");
            $countyLocales[] = new CountyLocale("Anne Arundel");
            $countyLocales[] = new CountyLocale("Baltimore City");
            $countyLocales[] = new CountyLocale("Baltimore County");
            $countyLocales[] = new CountyLocale("Calvert");
            $countyLocales[] = new CountyLocale("Caroline");
            $countyLocales[] = new CountyLocale("Carroll");
            $countyLocales[] = new CountyLocale("Cecil");
            $countyLocales[] = new CountyLocale("Charles");
            $countyLocales[] = new CountyLocale("Dorchester");
            $countyLocales[] = new CountyLocale("Frederick");
            $countyLocales[] = new CountyLocale("Garrett");
            $countyLocales[] = new CountyLocale("Harford");
            $countyLocales[] = new CountyLocale("Howard");
            $countyLocales[] = new CountyLocale("Kent");
            $countyLocales[] = new CountyLocale("Montgomery");
            $countyLocales[] = new CountyLocale("Prince George's");
            $countyLocales[] = new CountyLocale("Queen Anne's");
            $countyLocales[] = new CountyLocale("St. Mary's");
            $countyLocales[] = new CountyLocale("Somerset");
            $countyLocales[] = new CountyLocale("Talbot");
            $countyLocales[] = new CountyLocale("Washington");
            $countyLocales[] = new CountyLocale("Wicomico");
            $countyLocales[] = new CountyLocale("Worcester");
        } else if ($state == EState::DE) {
            $countyLocales[] = new CountyLocale("Kent");
            $countyLocales[] = new CountyLocale("New Castle");
            $countyLocales[] = new CountyLocale("Sussex");
        } else if ($state == EState::FL) {
            $countyLocales[] = new CountyLocale("All Others");
            $countyLocales[] = new CountyLocale("Miami-Dade");
        }

        return $countyLocales;
    }
    public function equals($name) {
        
        if ($this->getName() == $name) return true;

        return false;
    }
}
?>
